package com.cww.study.biz;

import com.alibaba.fastjson.JSON;
import com.cww.study.base.SysCode;
import com.cww.study.mybatis.PageResultBean;
import com.cww.study.po.User;
import com.cww.study.service.UserService;
import com.cww.study.vo.AddUserVO;
import com.cww.study.vo.QueryUserPageListVO;
import com.cww.study.vo.UpdateUserStateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @program: cww_project
 * @description:
 * @author: 陈亮
 * @create: 2022-03-12 13:38
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户")
public class UserBiz {

    @Resource
    private UserService userService;

    @ApiOperation(value = "注册用户/编辑保存用户")
    @PostMapping("/saveUser")
    @CrossOrigin
    public void saveUser(AddUserVO vo) {
        userService.saveUser(vo);
    }

    @ApiOperation(value = "登录之后获取用户信息")
    @PostMapping("/getLoginUserInfoByRedis")
    @CrossOrigin
    public User getLoginUserInfoByRedis(String loginName) {
        return userService.getLoginUserInfoByRedis(loginName);
    }

    @ApiOperation(value = "列表查询")
    @PostMapping("/queryUserPageList")
    @CrossOrigin
    public PageResultBean<User> queryUserPageList(QueryUserPageListVO vo) {
        return userService.queryUserPageList(vo);
    }

    @ApiOperation(value = "查看详情/页面回显")
    @PostMapping("/getDetailById")
    @CrossOrigin
    public User getDetailById(String id) {
        return userService.getDetailById(id);
    }

    @ApiOperation(value = "删除/禁用")
    @PostMapping("/updateUserState")
    @CrossOrigin
    public void updateUserState(UpdateUserStateVO vo) {
        userService.updateUserState(vo);
    }

}
